﻿// GameDlg.cpp : 茄君匡숭
//

#include "stdafx.h"
#include "GameDlg.h"
#include "afxdialogex.h"
#include "resource.h"

#include "InitConfig.h"

HWND   g_main_hwnd = NULL;
CGameDlg * g_main_cwnd = NULL;
HANDLE msdk_handle;


//int nI = 1;

// CGameDlg 뚤뺐움

int m_mapArr[4];
IMPLEMENT_DYNAMIC(CGameDlg, CDialogEx)

CGameDlg::CGameDlg(CWnd* pParent /*=NULL*/)
	: CDialogEx(IDD_GAME_DIALOG, pParent)
{

}

CGameDlg::~CGameDlg()
{
}

void CGameDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_COMBO1, cmb_type);
	DDX_Control(pDX, IDC_COMBO2, cmb_leftKey);
	DDX_Control(pDX, IDC_COMBO3, cmb_ji1);
	DDX_Control(pDX, IDC_COMBO4, cmb_xue);
	DDX_Control(pDX, IDC_COMBO5, cmb_gj1);
	DDX_Control(pDX, IDC_COMBO6, cmb_gj2);
	DDX_Control(pDX, IDC_COMBO7, cmb_bulan);
}


BEGIN_MESSAGE_MAP(CGameDlg, CDialogEx)
	ON_BN_CLICKED(IDC_BUTTON1, &CGameDlg::OnBnClickedButton1)
	ON_WM_HOTKEY()
	ON_WM_DESTROY()
	ON_BN_CLICKED(IDC_BUTTON2, &CGameDlg::OnBnClickedButton2)
	ON_BN_CLICKED(IDC_BUTTON3, &CGameDlg::OnBnClickedButton3)
	ON_BN_CLICKED(IDC_BUTTON4, &CGameDlg::OnBnClickedButton4)
	ON_BN_CLICKED(IDC_BUTTON5, &CGameDlg::OnBnClickedButton5)
END_MESSAGE_MAP()

void delayRandom(int d1, int d2) {
	Sleep(RandomNumber(d1, d2));
}

void buxue() {
	long x, y;
	g_dm->FindPic(0, 0, 900, 1200, L"xt.bmp", L"050505", 0.90, 0, &x, &y);
	CString str;
	str.Format(L"坐标%d,%d", x, y);
	g_main_cwnd->AppendText(str);
	if (x > 0) {

		CString str;

		int curSel = ((CComboBox*)g_main_cwnd->GetDlgItem(IDC_COMBO4))->GetCurSel();
		if (curSel != -1) {
			((CComboBox*)g_main_cwnd->GetDlgItem(IDC_COMBO4))->GetLBText(((CComboBox*)g_main_cwnd->GetDlgItem(IDC_COMBO4))->GetCurSel(), str);
			g_dm->KeyDown(mapKey[str]);
			delayRandom(110, 180);
			g_dm->KeyUp(mapKey[str]);
		}
		else {
			g_dm->KeyDown(35);
			delayRandom(110, 180);
			g_dm->KeyUp(35);
		}
		delayRandom(1210,1580);
	}
	//if (g_dm->CmpColor(550, 759, L"4f4d52", 0.9f) == 0) {

	//	M_KeyDown(msdk_handle, Keyboard_End);
	//	M_DelayRandom(130, 180);
	//	M_KeyUp(msdk_handle, Keyboard_End);
	//	M_DelayRandom(300, 400);
	//}
	//if (g_dm->CmpColor(470, 759, L"4f4d52", 0.9f) == 0) {
	//	M_KeyPress(msdk_handle, Keyboard_Insert, 1);
	//}
	g_main_cwnd->AppendText(g_dm->GetColor(500, 733));
}

void downJump() {
	
	g_dm->KeyDown(40);
	Sleep(RandomNumber(200, 300));
	g_dm->KeyDown(18);
	Sleep(RandomNumber(80, 120));

	g_dm->KeyUp(18);
	Sleep(RandomNumber(60, 90));
	g_dm->KeyUp(40);
	Sleep(RandomNumber(60, 90));
}

void dmJumpA() {

	g_dm->KeyDown(18);
	Sleep(RandomNumber(70, 100));
	g_dm->KeyUp(18);
	Sleep(RandomNumber(100, 130));

	g_dm->KeyDown(38);
	Sleep(RandomNumber(50, 80));
	g_dm->KeyUp(38);
	Sleep(RandomNumber(70, 90));

	g_dm->KeyDown(38);
	Sleep(RandomNumber(50, 80));
	g_dm->KeyUp(38);
	Sleep(RandomNumber(70, 90));




}

void jumpA() {

	//M_KeyDown(msdk_handle, Keyboard_LeftAlt);
	//M_DelayRandom(90, 150);
	//M_KeyUp(msdk_handle, Keyboard_LeftAlt);
	//M_DelayRandom(50, 80);

	//M_KeyDown(msdk_handle, Keyboard_UpArrow);
	//M_DelayRandom(50, 80);
	//M_KeyUp(msdk_handle, Keyboard_UpArrow);
	//M_DelayRandom(65, 80);

	//M_KeyDown(msdk_handle, Keyboard_UpArrow);
	//M_DelayRandom(300, 800);
	//M_KeyUp(msdk_handle, Keyboard_UpArrow);
	//M_DelayRandom(100, 120);

}

void gong3() {
	//long x, y;
	//int Keyboard = Keyboard_LeftArrow;
	//for (size_t i = 0; i < 10; i++)
	//{
	//	g_dm->FindPic(0, 0, m_mapArr[2], m_mapArr[3], L"localTag.bmp|localTag1.bmp|localTag2.bmp|localTag3.bmp|localTag4.bmp", L"050505", 0.9, 0, &x, &y);
	//	CString str;
	//	str.Format(L"坐标%d,%d", x, y);
	//	g_main_cwnd->AppendText(str);
	//	if (x > m_mapArr[2] - 40) {//往左攻击
	//		Keyboard = Keyboard_LeftArrow;
	//		M_KeyDown(msdk_handle, Keyboard);
	//		M_DelayRandom(130, 180);
	//		M_KeyUp(msdk_handle, Keyboard);
	//		M_DelayRandom(500, 1100);
	//	}
	//	if (x < 40) {//往右攻击
	//		Keyboard = Keyboard_RightArrow;
	//		M_KeyDown(msdk_handle, Keyboard);
	//		M_DelayRandom(130, 180);
	//		M_KeyUp(msdk_handle, Keyboard);
	//		M_DelayRandom(530, 1180);
	//	}
	//	
	//	M_KeyDown(msdk_handle, Keyboard_a);
	//	M_DelayRandom(230, 350);
	//	M_KeyUp(msdk_handle, Keyboard_a);
	//	M_DelayRandom(730, 1911);

	//	buxue();
	//	g_main_cwnd->AppendText(L"a打");

	//}
	
	long x, y;
	int Keyboard = 37;
	for (size_t i = 1; i < 11; i++)
	{
		g_dm->FindPic(0, 0, m_mapArr[2], m_mapArr[3], L"localTag.bmp|localTag1.bmp|localTag2.bmp|localTag3.bmp|localTag4.bmp", L"050505", 0.9, 0, &x, &y);
		CString str;
		str.Format(L"坐标%d,%d,%d,%d", x, y, m_mapArr[0], m_mapArr[2]);
		g_main_cwnd->AppendText(str);
		CButton* pBtn = (CButton*)g_main_cwnd->GetDlgItem(IDC_CHECK2);
		if (x > m_mapArr[2] - 40) {//往左攻击
			//if (pBtn->GetCheck() == 1) {
			//	g_dm->KeyDown(46);
			//	Sleep(RandomNumber(130, 180));
			//	g_dm->KeyUp(46);
			//	Sleep(RandomNumber(320, 700));
			//}
			Keyboard = 37;
			g_dm->KeyDown(Keyboard);
			Sleep(RandomNumber(130, 180));
			g_dm->KeyUp(Keyboard);
			Sleep(RandomNumber(320, 1170));
		}
		if (x < m_mapArr[0] + 40) {//往右攻击
			//if (pBtn->GetCheck() == 1) {
			//	g_dm->KeyDown(46);
			//	Sleep(RandomNumber(130, 180));
			//	g_dm->KeyUp(46);
			//	Sleep(RandomNumber(320, 700));
			//}
			Keyboard = 39;
			g_dm->KeyDown(Keyboard);
			Sleep(RandomNumber(130, 180));
			g_dm->KeyUp(Keyboard);
			Sleep(RandomNumber(320, 1170));

		}
		//M_DelayRandom(200, 500);
		int curSel = ((CComboBox*)g_main_cwnd->GetDlgItem(IDC_COMBO5))->GetCurSel();
		if (curSel != -1) {
			((CComboBox*)g_main_cwnd->GetDlgItem(IDC_COMBO5))->GetLBText(((CComboBox*)g_main_cwnd->GetDlgItem(IDC_COMBO5))->GetCurSel(), str);
			g_dm->KeyDown(mapKey[str]);
			//Sleep(RandomNumber(130, 350));
			Sleep(RandomNumber(500, 1000));
			g_dm->KeyUp(mapKey[str]);
			Sleep(RandomNumber(430, 1511));
			g_main_cwnd->AppendText(L"a打");
		}
		else {
			g_dm->KeyDown(65);
			Sleep(RandomNumber(230, 350));
			g_dm->KeyUp(65);
			Sleep(RandomNumber(430, 1211));
			g_main_cwnd->AppendText(L"a打");
		}


		//CButton* pBtn = (CButton*)g_main_cwnd->GetDlgItem(IDC_CHECK2);
		if (pBtn->GetCheck() == 1) {
			g_dm->FindPic(0, 0, 1280, 960, L"dun.bmp", L"101010", 0.9, 0, &x, &y);
			if (x > 0) {
				str.Format(L"盾牌攻击%d", i);
				g_main_cwnd->AppendText(str);
				Sleep(RandomNumber(200, 550));
				g_dm->KeyDown(16);
				Sleep(RandomNumber(230, 350));
				g_dm->KeyUp(16);
				Sleep(RandomNumber(430, 811));
			}
		}
		buxue();
	}
}

void gong2() {//左右a跳攻
	//if(m_mapArr[0])
	long x, y;
	int Keyboard = 37;
	for (size_t i = 0; i < 10; i++)
	{
		g_dm->FindPic(0, 0, m_mapArr[2], m_mapArr[3], L"localTag.bmp|localTag1.bmp|localTag2.bmp|localTag3.bmp|localTag4.bmp", L"050505", 0.9, 0, &x, &y);
		CString str;
		str.Format(L"坐标%d,%d,%d,%d", x, y, m_mapArr[0], m_mapArr[2]);
		g_main_cwnd->AppendText(str);
		if (x > m_mapArr[2] - 40) {//往左攻击
			Keyboard = 37;
			g_dm->KeyDown(Keyboard);
			Sleep(RandomNumber(130, 180));
			Sleep(RandomNumber(120, 170));
			g_dm->KeyUp(Keyboard);
			Sleep(RandomNumber(320, 1170));
		}
		if (x < m_mapArr[0]+40) {//往右攻击
			Keyboard = 39;
			g_dm->KeyDown(Keyboard);
			Sleep(RandomNumber(130, 180));
			g_dm->KeyUp(Keyboard);
			Sleep(RandomNumber(320, 1170));
		}
		//M_DelayRandom(200, 500);
		if (x > m_mapArr[0]+60 && x < m_mapArr[0]+130) {

			g_dm->KeyDown(65);
			Sleep(RandomNumber(230, 350));
			g_dm->KeyUp(65);
			Sleep(RandomNumber(730, 1911));

			g_dm->KeyDown(18);
			Sleep(RandomNumber(50, 120));
			g_dm->KeyUp(18);
			Sleep(RandomNumber(100, 150));

			g_dm->KeyDown(16);
			Sleep(RandomNumber(230, 350));
			g_dm->KeyUp(16);
			Sleep(RandomNumber(430, 811));
			g_main_cwnd->AppendText(L"跳打");
		}
		else {
			g_dm->KeyDown(65);
			Sleep(RandomNumber(230, 350));
			g_dm->KeyUp(65);
			Sleep(RandomNumber(430, 1211));
			g_main_cwnd->AppendText(L"a打");
		}
		buxue();
	}
}

void dmGong1() {
	
	//Sleep(RandomNumber(300, 600));
	g_dm->KeyDown(16);
	Sleep(RandomNumber(3000, 4000));
	g_dm->KeyUp(16);
	Sleep(RandomNumber(500, 1000));
	buxue();
	Sleep(RandomNumber(300, 500));
	
	dmJumpA();
	g_dm->KeyDown(16);
	Sleep(RandomNumber(3000, 4000));
	g_dm->KeyUp(16);
	Sleep(RandomNumber(500, 1000));
	buxue();
	
	downJump();
	buxue();


	//Sleep(500);
	////Sleep(RandomNumber(300, 600));
	//for (size_t i = 0; i < 10; i++)
	//{
	//	g_dm->KeyPress(16);
	//	//g_dm->KeyDown(16);
	//	//Sleep(RandomNumber(100, 200));
	//	//g_dm->KeyUp(16);
	//	Sleep(RandomNumber(300, 550));
	//	
	//}
	//buxue();
	//Sleep(RandomNumber(300, 500));

	////Sleep(RandomNumber(300, 500));
	//
	//dmJumpA();
	////for (size_t i = 0; i < RandomNumber(3, 5); i++)
	////{
	////	g_dm->KeyDown(16);
	////	Sleep(RandomNumber(100, 200));
	////	g_dm->KeyUp(16);
	////	Sleep(RandomNumber(800, 1300));
	////}
	//for (size_t i = 0; i < 10; i++)
	//{
	//	g_dm->KeyPress(16);
	//	//g_dm->KeyDown(16);
	//	//Sleep(RandomNumber(100, 200));
	//	//g_dm->KeyUp(16);
	//	Sleep(RandomNumber(300, 550));
	//	
	//}
	//buxue();
	//Sleep(RandomNumber(300, 500));
	//downJump();
	//buxue();
	
}


void gong4() {
	Sleep(RandomNumber(500, 1000));
	int nUp = g_main_cwnd->GetDlgItemInt(IDC_EDIT2);
	int nDown = g_main_cwnd->GetDlgItemInt(IDC_EDIT3);
	int nDelay = g_main_cwnd->GetDlgItemInt(IDC_EDIT4);
	int rnd = 0;
	CString str;
	long x, y;
	CButton* pBtn = (CButton*)g_main_cwnd->GetDlgItem(IDC_CHECK2);

	for (size_t i = 0; i < nUp; i++)
	{
		g_dm->KeyDown(16);
		rnd = RandomNumber(nDelay * 1000, nDelay * 1000 + 150);
		Sleep(rnd);
		g_dm->KeyUp(16);
		Sleep(RandomNumber(500, 1000));
		
		Sleep(RandomNumber(300, 500));
	
		if (pBtn->GetCheck() == 1) {
			g_dm->FindPic(0, 0, 1280, 960, L"dun.bmp", L"101010", 0.9, 0, &x, &y);
			if (x > 0) {
				str.Format(L"盾牌攻击");
				g_main_cwnd->AppendText(str);
				Sleep(RandomNumber(100, 300));
				g_dm->KeyDown(36);
				Sleep(RandomNumber(230, 350));
				g_dm->KeyUp(36);
				Sleep(RandomNumber(430, 811));
			}
		}
		buxue();
		dmJumpA();
	}
	for (size_t i = 0; i <  nDown; i++)
	{
		g_dm->KeyDown(16);
		rnd = RandomNumber(nDelay * 1000, nDelay * 1000 + 150);
		Sleep(rnd);
		g_dm->KeyUp(16);
		Sleep(RandomNumber(500, 1000));
		//Sleep(RandomNumber(500, 1000));

		if (pBtn->GetCheck() == 1) {
			g_dm->FindPic(0, 0, 1280, 960, L"dun.bmp", L"101010", 0.9, 0, &x, &y);
			if (x > 0) {
				str.Format(L"盾牌攻击");
				g_main_cwnd->AppendText(str);
				Sleep(RandomNumber(100, 300));
				g_dm->KeyDown(36);
				Sleep(RandomNumber(230, 350));
				g_dm->KeyUp(36);
				Sleep(RandomNumber(430, 811));
			}
		}
		downJump();
		buxue();
	}


}
void gong5() {

	g_dm->KeyDown(mapKey[L"left"]);
	Sleep(RandomNumber(400, 600));
	g_dm->KeyUp(mapKey[L"left"]);
	Sleep(RandomNumber(210, 350));

	CString str;
	((CComboBox*)g_main_cwnd->GetDlgItem(IDC_COMBO2))->GetLBText(((CComboBox*)g_main_cwnd->GetDlgItem(IDC_COMBO2))->GetCurSel(), str);

	g_dm->KeyDown(mapKey[str]);
	Sleep(RandomNumber(5000, 5800));
	g_dm->KeyUp(mapKey[str]);
	Sleep(RandomNumber(113, 300));
	buxue();


	/*for (size_t i = 0; i < 5; i++)
	{
		g_dm->KeyDown(16);
		Sleep(RandomNumber(110, 350));
		g_dm->KeyUp(16);
		Sleep(RandomNumber(600, 1000));
		buxue();
	}
	dmJumpA();
	for (size_t i = 0; i < 5; i++)
	{
		g_dm->KeyDown(16);
		Sleep(RandomNumber(120, 300));
		g_dm->KeyUp(16);
		Sleep(RandomNumber(700, 1100));
		buxue();
	}
	downJump();
	buxue();*/
}
void gong1() {
	//Sleep(M_RandDomNbr(300, 600));
	//M_KeyDown(msdk_handle, Keyboard_LeftShift);
	//Sleep(M_RandDomNbr(3000, 4000));
	//M_KeyUp(msdk_handle, Keyboard_LeftShift);
	//Sleep(M_RandDomNbr(500, 1000));
	//buxue();
	//Sleep(M_RandDomNbr(300, 500));
	//M_ReleaseAllKey(msdk_handle);
	//jumpA();
	//M_KeyDown(msdk_handle, Keyboard_LeftShift);
	//Sleep(M_RandDomNbr(3000, 4000));
	//M_KeyUp(msdk_handle, Keyboard_LeftShift);
	//Sleep(M_RandDomNbr(500, 1000));
	//buxue();
	//M_ReleaseAllKey(msdk_handle);
	//Sleep(M_RandDomNbr(500, 1000));
	//downJump();
	//buxue();
	//M_ReleaseAllKey(msdk_handle);
	//Sleep(500);
}
void gong61() {
	long x, y;
	long pointx = (long)g_main_cwnd->GetDlgItemInt(IDC_EDIT5);
	int num = RandomNumber(1, 2);
	for (size_t i = 0; i < num; i++)
	{
		g_dm->FindPic(0, 0, m_mapArr[2], m_mapArr[3], L"localTag.bmp|localTag1.bmp|localTag2.bmp|localTag3.bmp|localTag4.bmp", L"050505", 0.9, 0, &x, &y);
		if (x < pointx - 5) {
			g_dm->KeyDown(mapKey[L"right"]);
			Sleep(RandomNumber(800, 2000));
			g_dm->KeyUp(mapKey[L"right"]);
			Sleep(RandomNumber(100, 200));
		}
		if (x > pointx + 5) {
			g_dm->KeyDown(mapKey[L"left"]);
			Sleep(RandomNumber(800, 2000));
			g_dm->KeyUp(mapKey[L"left"]);
			Sleep(RandomNumber(100, 200));
		}
		Sleep(RandomNumber(500, 1000));
		g_dm->KeyDown(mapKey[L"ctrl"]);
		Sleep(RandomNumber(500, 1000));
		g_dm->KeyUp(mapKey[L"ctrl"]);
		Sleep(RandomNumber(80, 200));
		g_dm->KeyDown(mapKey[L"ctrl"]);
		Sleep(RandomNumber(80, 200));
		g_dm->KeyDown(mapKey[L"left"]);
		Sleep(RandomNumber(800, 1300));
		g_dm->KeyUp(mapKey[L"left"]);
		Sleep(RandomNumber(100, 150));
		//g_dm->KeyUp(mapKey[L"ctrl"]);
		//Sleep(RandomNumber(500, 1000));
		//g_dm->KeyDown(mapKey[L"ctrl"]);
		Sleep(RandomNumber(80, 200));
		g_dm->KeyDown(mapKey[L"right"]);
		Sleep(RandomNumber(800, 1500));
		g_dm->KeyUp(mapKey[L"right"]);
		Sleep(RandomNumber(100, 150));
		g_dm->KeyUp(mapKey[L"ctrl"]);
		buxue();
	}
	g_dm->FindPic(0, 0, m_mapArr[2], m_mapArr[3], L"localTag.bmp|localTag1.bmp|localTag2.bmp|localTag3.bmp|localTag4.bmp", L"050505", 0.9, 0, &x, &y);
	if (x < pointx - 5) {
		g_dm->KeyDown(mapKey[L"right"]);
		Sleep(RandomNumber(500, 1300));
		g_dm->KeyUp(mapKey[L"right"]);
		Sleep(RandomNumber(100, 200));
	}
	if (x > pointx + 5) {
		g_dm->KeyDown(mapKey[L"left"]);
		Sleep(RandomNumber(500, 1300));
		g_dm->KeyUp(mapKey[L"left"]);
		Sleep(RandomNumber(100, 200));
	}
	//if (k <= 1) {

	//	Sleep(RandomNumber(500, 1150));
	//	g_dm->KeyDown(mapKey[L"a"]);
	//	Sleep(RandomNumber(80, 150));
	//	g_dm->KeyUp(mapKey[L"a"]);
	//	Sleep(RandomNumber(1000, 1500));
	//}
	//else {
	//	//g_dm->KeyUp(mapKey[L"ctrl"]);
	//	Sleep(RandomNumber(500, 1100));
	//	downJump();
	//	Sleep(RandomNumber(100, 200));
	//}
}

void gong6() {

	int nUp= g_main_cwnd->GetDlgItemInt(IDC_EDIT2);
	int nDown = g_main_cwnd->GetDlgItemInt(IDC_EDIT3);
	for (int i = 0; i < nUp; i++)
	{
		gong61();
		Sleep(RandomNumber(500, 1150));
		g_dm->KeyDown(mapKey[L"a"]);
		Sleep(RandomNumber(80, 150));
		g_dm->KeyUp(mapKey[L"a"]);
		Sleep(RandomNumber(1000, 1500));
	}
	for (size_t i = 0; i < nDown; i++)
	{
		gong61();
		//g_dm->KeyUp(mapKey[L"ctrl"]);
		Sleep(RandomNumber(500, 1100));
		downJump();
		Sleep(RandomNumber(100, 200));
	}

}


void gong7() {
	long x, y;
	int Keyboard = 37;
	g_dm->FindPic(0, 0, m_mapArr[2], m_mapArr[3], L"localTag.bmp|localTag1.bmp|localTag2.bmp|localTag3.bmp|localTag4.bmp", L"050505", 0.9, 0, &x, &y);
	CString str;
	str.Format(L"坐标%d,%d,%d,%d", x, y, m_mapArr[0], m_mapArr[2]);
	g_main_cwnd->AppendText(str);
	CButton* pBtn = (CButton*)g_main_cwnd->GetDlgItem(IDC_CHECK2);
	//if (x > m_mapArr[2] - 40) {
	//	//往左攻击
	//						   //if (pBtn->GetCheck() == 1) {
	//						   //	g_dm->KeyDown(46);
	//						   //	Sleep(RandomNumber(130, 180));
	//						   //	g_dm->KeyUp(46);
	//						   //	Sleep(RandomNumber(320, 700));
	//						   //}
	//	Keyboard = 37;
	//	g_dm->KeyDown(Keyboard);
	//	Sleep(RandomNumber(130, 180));
	//	g_dm->KeyUp(Keyboard);
	//	Sleep(RandomNumber(320, 1570));
	//}
	//if (x < m_mapArr[0] + 40) {//往右攻击
	//						   //if (pBtn->GetCheck() == 1) {
	//						   //	g_dm->KeyDown(46);
	//						   //	Sleep(RandomNumber(130, 180));
	//						   //	g_dm->KeyUp(46);
	//						   //	Sleep(RandomNumber(320, 700));
	//						   //}
	//	Keyboard = 39;
	//	g_dm->KeyDown(Keyboard);
	//	Sleep(RandomNumber(130, 180));
	//	g_dm->KeyUp(Keyboard);
	//	Sleep(RandomNumber(320, 1570));

	//}
	//M_DelayRandom(200, 500);


	int curSel = ((CComboBox*)g_main_cwnd->GetDlgItem(IDC_COMBO5))->GetCurSel();
	if (curSel != -1) {
		((CComboBox*)g_main_cwnd->GetDlgItem(IDC_COMBO5))->GetLBText(((CComboBox*)g_main_cwnd->GetDlgItem(IDC_COMBO5))->GetCurSel(), str);
		g_dm->KeyDown(mapKey[str]);
		Sleep(RandomNumber(130, 250));
		g_dm->KeyUp(mapKey[str]);
		Sleep(RandomNumber(500, 1100));
		g_main_cwnd->AppendText(L"a打");
	}
	curSel = ((CComboBox*)g_main_cwnd->GetDlgItem(IDC_COMBO6))->GetCurSel();
	if (curSel != -1) {
		((CComboBox*)g_main_cwnd->GetDlgItem(IDC_COMBO6))->GetLBText(((CComboBox*)g_main_cwnd->GetDlgItem(IDC_COMBO6))->GetCurSel(), str);
		g_dm->KeyDown(mapKey[str]);
		Sleep(RandomNumber(130, 350));
		g_dm->KeyUp(mapKey[str]);
		Sleep(RandomNumber(500, 1000));
		g_main_cwnd->AppendText(L"a打");
	}

	g_dm->FindPic(0, 0, m_mapArr[2], m_mapArr[3], L"localTag.bmp|localTag1.bmp|localTag2.bmp|localTag3.bmp|localTag4.bmp", L"050505", 0.9, 0, &x, &y);
	str.Format(L"坐标%d,%d,%d,%d", x, y, m_mapArr[0], m_mapArr[2]);
	g_main_cwnd->AppendText(str);
	if (x > m_mapArr[2] - 40) {
		//往左攻击
		//if (pBtn->GetCheck() == 1) {
		//	g_dm->KeyDown(46);
		//	Sleep(RandomNumber(130, 180));
		//	g_dm->KeyUp(46);
		//	Sleep(RandomNumber(320, 700));
		//}
		Keyboard = 37;
		g_dm->KeyDown(Keyboard);
		Sleep(RandomNumber(130, 180));
		g_dm->KeyUp(Keyboard);
		Sleep(RandomNumber(320, 1570));
	}
	if (x < m_mapArr[0] + 40) {//往右攻击
							   //if (pBtn->GetCheck() == 1) {
							   //	g_dm->KeyDown(46);
							   //	Sleep(RandomNumber(130, 180));
							   //	g_dm->KeyUp(46);
							   //	Sleep(RandomNumber(320, 700));
							   //}
		Keyboard = 39;
		g_dm->KeyDown(Keyboard);
		Sleep(RandomNumber(130, 180));
		g_dm->KeyUp(Keyboard);
		Sleep(RandomNumber(320, 1570));

	}
	buxue();
}


void gong8() {

	int rnd = RandomNumber(0, 1);//0左1.右

	long x, y;

	g_dm->FindPic(0, 0, m_mapArr[2], m_mapArr[3], L"localTag.bmp|localTag1.bmp|localTag2.bmp|localTag3.bmp|localTag4.bmp", L"050505", 0.9, 0, &x, &y);

	//取范围
	int nPointX= g_main_cwnd->GetDlgItemInt(IDC_EDIT6);

	//取攻击键
	int curSel = ((CComboBox*)g_main_cwnd->GetDlgItem(IDC_COMBO5))->GetCurSel();

	//取定点
	int nFixedX = g_main_cwnd->GetDlgItemInt(IDC_EDIT5);
	
	//1.点击攻击键盘 4-6 秒

	//当前人物坐标>定点+范围 
	if (x  > nFixedX+ nPointX) {
		//往左移动
	}

	if (x  < nFixedX+ nPointX) {
		//往右移动
	}

	//当前人物坐标<定点范围


}
// CGameDlg 句口뇹잿넋埼
unsigned WINAPI SubThread(PVOID pParam)
{
	//g_dm->SetSimMode(1);
	//long hwnd = g_dm->FindWindow(L"MapleStoryClass", L"MapleStory");

	//if (g_dm->GetBindWindow() == 0) {
	//	g_dm->BindWindowEx(hwnd, L"normal", L"normal", L"normal", L"", 0);
	//}

	//g_dm->delay(5000);
	//for (size_t i = 0; i < 20; i++)
	//{
	//	//Sleep(200);
	//	//g_dm->KeyDown(16);
	//	//g_dm->delay(200);
	//	//g_dm->KeyUp(16);
	//	//Sleep(200);

	//	
	//	
	//}
	long x, y;
	int i = 0;
	int nJn = RandomNumber(175, 180);
	CString str;
	while (true)
	{

		if (nI == 1 || nI % nJn == 0) {
			jnState = true;
			nI = 1;
		}
		str.Format(L"nI=%d,s=%d",nI,nJn);

		g_main_cwnd->AppendText(str);
		g_ckdm->FindPic(0, 0, m_mapArr[2] + 100, m_mapArr[3] + 100, L"fuwen.bmp|fuwen1.bmp", L"050505", 0.96, 0, &x, &y);
		if (x > 0) {
			g_ckdm->SetWindowState((long)g_main_cwnd->m_hWnd, 12);
			//AfxMessageBox(L"出现符文");
			g_main_cwnd->OnBnClickedButton2();
		}
		//dmCheck.FindPic(0, 0, m_minArr[2] + 1, m_minArr[3] + 1, "fuwen.bmp|fuwen1.bmp", "050505", 0.9, 0, out x, out y);
		CButton* pBtn = (CButton*)g_main_cwnd->GetDlgItem(IDC_CHECK1); 
		if (pBtn->GetCheck()==1) {
			g_dm->FindPic(0, 0, 900, 1200, L"xt.bmp", L"050505", 0.90, 0, &x, &y);
			
			str.Format(L"线程坐标%d,%d", x, y);
			if (x > 0) {
				g_ckdm->KeyDown(35);
				delayRandom(110, 180);
				g_ckdm->KeyUp(35);
				delayRandom(1210, 1580);
			}
		}

		CButton* pBtnQs = (CButton*)g_main_cwnd->GetDlgItem(IDC_CHECK1);
		if (pBtnQs->GetCheck() == 1) {
			g_dm->FindPic(0, 0, 900, 1200, L"xue.bmp", L"050505", 0.90, 0, &x, &y);

			str.Format(L"血条%d,%d", x, y);
			if (x == -1) {
				g_ckdm->KeyDown(35);
				delayRandom(110, 180);
				g_ckdm->KeyUp(35);
				delayRandom(1210, 1580);
			}

			g_dm->FindPic(0, 0, 900, 1200, L"lan.bmp", L"050505", 0.90, 0, &x, &y);
			str.Format(L"蓝条%d,%d", x, y);
			if (x == -1) {
				g_ckdm->KeyDown(35);
				delayRandom(110, 180);
				g_ckdm->KeyUp(35);
				delayRandom(1210, 1580);
			}

		}


		g_ckdm->FindPic(0, 0, 900, 1200, L"xt1.bmp", L"151515", 0.90, 0, &x, &y);
		if (x > 0) {
			g_ckdm->KeyDown(36);
			g_ckdm->delay(200);
			g_ckdm->KeyUp(36);
		}
		CButton* pBtnJi = (CButton*)g_main_cwnd->GetDlgItem(IDC_CHECK3);
		if (pBtnJi->GetCheck() == 1) {
			if (i > 120 || i==0) {
				
				i = 1;
				g_ckdm->KeyDown(229);
				delayRandom(110, 180);
				g_ckdm->KeyUp(229);
				delayRandom(1210, 1580);
			}
		}
		i++;
		if (i > 120) {
			g_main_cwnd->SetDlgItemTextW(IDC_EDIT1, L"");
			i = 0;
		}
		Sleep(1000);
		nI++;

	}
	return 0;
}
unsigned WINAPI MainThread(PVOID pParam)
{
	long x, y;
	g_dm->FindPic(0, 0, 500, 380, L"minMapLeft.bmp", L"202020", 0.9, 0, &x,&y);
	m_mapArr[0] = x;
	m_mapArr[1] = 80;

	g_dm->FindPic(0, 0, 600, 400, L"minMap.bmp", L"000000", 0.98, 0, &x, &y);
	m_mapArr[2] = x+15;
	m_mapArr[3] = y+50;


	//定位左右坐标
	unsigned int RetSw;
	g_main_cwnd->AppendText(L"开始");
	
	int k = 0,j=1,l=0,s= RandomNumber(251, 280);
	CString str;
	((CComboBox*)g_main_cwnd->GetDlgItem(IDC_COMBO1))->GetLBText(((CComboBox*)g_main_cwnd->GetDlgItem(IDC_COMBO1))->GetCurSel(), str);
	int curSel=((CComboBox*)g_main_cwnd->GetDlgItem(IDC_COMBO1))->GetCurSel();
	if (curSel == -1) {
		AfxMessageBox(L"请选择攻击模式");
		return 0;
	}
	int nNum = RandomNumber(3, 7);
	int nJi = RandomNumber(255, 280);
	while (state)
	{
	
		if (jnState) {
			int nSel=((CComboBox*)g_main_cwnd->GetDlgItem(IDC_COMBO8))->GetCurSel();
			((CComboBox*)g_main_cwnd->GetDlgItem(IDC_COMBO8))->GetLBText(nSel, str);
			Sleep(RandomNumber(2000, 3500));
			if (nSel != -1) {
				g_dm->KeyDown(mapKey[str]);
				g_dm->delay(RandomNumber(90, 150));
				g_dm->KeyUp(mapKey[str]);
				g_dm->delay(RandomNumber(290, 550));
			}
			jnState = false;
		}
		if (curSel == 0) {
			dmGong1();
		}
		else if (curSel == 1) {
			gong2();
		}
		else if (curSel == 2) {
			gong3();
		}
		else if (curSel == 3) {
			Sleep(RandomNumber(500, 1000));
			g_dm->KeyDown(16);
			Sleep(RandomNumber(100, 200));
			g_dm->KeyUp(16);
			Sleep(RandomNumber(5500, 5900));
			CString str1;
			str1.Format(L"攻击开始 ", nNum, j, (nNum % j));
			g_main_cwnd->AppendText(str1);
			if (nNum % j == 0) {//攻击次数
				if (l == 0) {//左
					g_dm->KeyDown(37);
					Sleep(RandomNumber(700, 750));
					g_dm->KeyUp(37);
					Sleep(RandomNumber(100, 200));
					l = 1;
					g_main_cwnd->AppendText(L"左");
				}
				else {//右
					g_dm->KeyDown(39);
					Sleep(RandomNumber(700, 750));
					g_dm->KeyUp(39);
					Sleep(RandomNumber(100, 200));
					l = 0;
					g_main_cwnd->AppendText(L"右");
				}
				nNum = RandomNumber(3, 7);
				j = 1;
			}
			j++;

		}
		else if (curSel == 4) {
			gong4();
		}
		else if (curSel == 5) {
			gong5();
		}
		else if (curSel == 6) {
			gong6();
		}
		else if (curSel == 7) {
			gong7();
		}
		else if (curSel == 8) {
			int nSel = ((CComboBox*)g_main_cwnd->GetDlgItem(IDC_COMBO5))->GetCurSel();
			if (nSel != -1) {
				((CComboBox*)g_main_cwnd->GetDlgItem(IDC_COMBO5))->GetLBText(nSel, str);
				Sleep(RandomNumber(500, 1000));
				g_dm->KeyDown(mapKey[str]);
				Sleep(RandomNumber(4010, 5100));
				g_dm->KeyUp(mapKey[str]);
				Sleep(RandomNumber(200, 700));
			}
			CString str1;
			str1.Format(L"攻击开始 ", nNum, j, (nNum % j));
			g_main_cwnd->AppendText(str1);
				if (l == 0) {//左
					g_dm->KeyUp(mapKey[str]);
					Sleep(RandomNumber(500, 1000));
					g_dm->KeyUp(39);
					Sleep(RandomNumber(500, 1000));
					g_dm->KeyDown(37);
					Sleep(RandomNumber(120, 150));
					g_dm->KeyUp(37);
					//g_dm->KeyPress(37);
					Sleep(RandomNumber(500, 1000));
					l = 1;
					g_main_cwnd->AppendText(L"左");
				}
				else {//右
					g_dm->KeyUp(37);
					Sleep(RandomNumber(500, 1000));
					g_dm->KeyUp(mapKey[str]);
					Sleep(RandomNumber(500, 1000));
					//g_dm->KeyPress(39);
					g_dm->KeyDown(39);
					Sleep(RandomNumber(120, 150));
					g_dm->KeyUp(39);
					Sleep(RandomNumber(500, 1000));
					l = 0;
					g_main_cwnd->AppendText(L"右");
				}
				nNum = RandomNumber(3, 7);

				//定位处理
				//如果当前人物坐标>定点坐标 往左移动
				//如果当前任务坐标<定点坐标 往右移动


				//j = 1;
			
			//j++;
		}
		//CString str;
		str.Format(L"第%d次,nI=%d,s=%d", k,nI,s);
		k++;
	
		//g_main_cwnd->AppendText(str);
	}
	//int cl = M_Close(msdk_handle);
	g_main_cwnd->GetDlgItem(IDC_BUTTON1)->EnableWindow(TRUE);
	g_main_cwnd->SetDlgItemTextW(IDC_BUTTON1,L"开始");
	return 0;
}


void CGameDlg::OnBnClickedButton1()
{
	CString str;
	((CComboBox*)g_main_cwnd->GetDlgItem(IDC_COMBO1))->GetLBText(((CComboBox*)g_main_cwnd->GetDlgItem(IDC_COMBO1))->GetCurSel(), str);

	state = true;
	GetDlgItem(IDC_BUTTON1)->EnableWindow(FALSE);
	SetDlgItemTextW(IDC_BUTTON1, L"结束");

	hThread = (HANDLE)_beginthreadex(0, 0, MainThread, NULL, 0, 0);
	hThread1 = (HANDLE)_beginthreadex(0, 0, SubThread, NULL, 0, 0);
}



BOOL CGameDlg::OnInitDialog()
{
	CDialogEx::OnInitDialog();
	msdk_handle = INVALID_HANDLE_VALUE;	//初始为未打开
	CString result;
	//long ret3 = g_dm->SetSimMode(0);
	//long hwnd = g_dm->FindWindow(L"MapleStoryClass", L"MapleStory");

	//int ret = g_dm->BindWindowEx(hwnd, L"normal", L"normal", L"normal", L"", 0);

	//result.Format(L"%d", ret3);
	//AfxMessageBox(result);

	// TODO:  瞳늪警속띨棍돨놓迦뺏
	CString l_Str;
	//if (msdk_handle != INVALID_HANDLE_VALUE) {
	//	AfxMessageBox(L"端口已经打开，请关闭端口再重新打开");
	//}
	//msdk_handle = M_Open(1);
	//if (msdk_handle == INVALID_HANDLE_VALUE) {
	//	AfxMessageBox(L"端口打开失败，请确认您的USB设备已经插上电脑");
	//}
	//else {
	//	//GetDlgItem(IDC_BUTTON_UIOPEN)->EnableWindow(false);
	//}
	//GetDlgItem(IDC_COMBO1)

	mapKey[L"1"] = 49;
	mapKey[L"2"] = 50;
	mapKey[L"3"] = 51;
	mapKey[L"4"] = 52;
	mapKey[L"5"] = 53;
	mapKey[L"6"] = 54;
	mapKey[L"7"] = 55;
	mapKey[L"8"] = 56;
	mapKey[L"9"] = 57;
	mapKey[L"0"] = 48;

	mapKey[L"a"] = 65;
	mapKey[L"b"] = 66;
	mapKey[L"c"] = 67;
	mapKey[L"d"] = 68;
	mapKey[L"e"] = 69;
	mapKey[L"f"] = 70;
	mapKey[L"g"] = 71;
	mapKey[L"h"] = 72;
	mapKey[L"i"] = 73;
	mapKey[L"j"] = 74;
	mapKey[L"k"] = 75;
	mapKey[L"l"] = 76;
	mapKey[L"m"] = 77;
	mapKey[L"n"] = 78;
	mapKey[L"o"] = 79;
	mapKey[L"p"] = 80;
	mapKey[L"q"] = 81;
	mapKey[L"r"] = 82;
	mapKey[L"s"] = 83;
	mapKey[L"t"] = 84;
	mapKey[L"u"] = 85;
	mapKey[L"v"] = 86;
	mapKey[L"w"] = 87;
	mapKey[L"x"] = 88;
	mapKey[L"y"] = 89;
	mapKey[L"z"] = 90;

	mapKey[L"ctrl"] = 17;
	mapKey[L"alt"] = 18;
	mapKey[L"shift"] = 16;
	mapKey[L"up"] = 38;
	mapKey[L"down"] = 40;
	mapKey[L"left"] = 37;
	mapKey[L"right"] = 39;

	mapKey[L"delete"] = 46;
	mapKey[L"home"] = 36;
	mapKey[L"end"] = 35;
	mapKey[L"pgup"] = 33;
	mapKey[L"pgdn"] = 34;
	map<CString, int>::iterator iter;//定义一个迭代指针iter
	for (iter = mapKey.begin(); iter != mapKey.end(); iter++)
	{
		cmb_leftKey.InsertString(0, iter->first);
		cmb_ji1.InsertString(0, iter->first);
		cmb_xue.InsertString(0, iter->first);
		cmb_gj1.InsertString(0, iter->first);
		cmb_gj2.InsertString(0, iter->first);
		cmb_bulan.InsertString(0, iter->first);
	}
	//return 0;



	cmb_type.InsertString(0, L"上下跳打");
	cmb_type.InsertString(1, L"左右跳打");
	cmb_type.InsertString(2, L"A打");
	cmb_type.InsertString(3, L"技能攻击");
	cmb_type.InsertString(4, L"自定义跳打");
	cmb_type.InsertString(5, L"左攻");
	cmb_type.InsertString(6, L"定点攻击");
	cmb_type.InsertString(7, L"A打1");
	cmb_type.InsertString(8, L"自定义技能攻击");
	//CString s=;
	RegisterHotKey(this->m_hWnd, 1000, NULL, VK_F8);//注册热键
	RegisterHotKey(this->m_hWnd, 2000, NULL, VK_F9);//注册热键
	//CppSQLite3DB db;
	CFileFind fFind;
	g_main_cwnd = this;

	
	return TRUE;  // return TRUE unless you set the focus to a control
				  // 嫩끽: OCX 橄昑女壇럿쀼 FALSE
}
void CGameDlg::AppendText(CString str)
{
	((CEdit*)GetDlgItem(IDC_EDIT1))->SetSel(GetDlgItem(IDC_EDIT1)->GetWindowTextLength(), GetDlgItem(IDC_EDIT1)->GetWindowTextLength());
	((CEdit*)GetDlgItem(IDC_EDIT1))->ReplaceSel(str + L"\r\n");
}





void CGameDlg::OnHotKey(UINT nHotKeyId, UINT nKey1, UINT nKey2)
{
	// TODO: 在此添加消息处理程序代码和/或调用默认值
	//AfxMessageBox(L"key");
	//TRACE("%d,%d,%d", nHotKeyId, nKey1, nKey2);

	if (nHotKeyId == 1000 && (long)hThread<=0) {
		//TRACE("%d,%d,%d", nHotKeyId, nKey1, nKey2);
		OnBnClickedButton1();
	}
	if (nHotKeyId == 2000 && (long)hThread > 0) {
		if (AfxMessageBox(L"你确定停止游戏吗？", MB_YESNO) == IDYES)
		{
			state = false;
			CString str = L"";
			CloseHandle(hThread);
			hThread = NULL;
			//M_ReleaseAllKey(msdk_handle);
			//int cl = M_Close(msdk_handle);
			//msdk_handle = INVALID_HANDLE_VALUE;	//初始为未打开
		}

		
	}
	CDialogEx::OnHotKey(nHotKeyId, nKey1, nKey2);
}


void CGameDlg::OnDestroy()
{
	//M_ReleaseAllKey(msdk_handle);
	//if (msdk_handle != INVALID_HANDLE_VALUE) {
	//	int cl = M_Close(msdk_handle);
	//}
	UnregisterHotKey(m_hWnd, 1000);
	CDialogEx::OnDestroy();

	// TODO: 在此处添加消息处理程序代码
}


void CGameDlg::OnBnClickedButton2()
{
	// TODO: 在此添加控件通知处理程序代码
	//state = false;
	//CString str = L"";
	//Sleep(1000);
	//if ((long)hThread > 0) {
	//	WaitForSingleObject(hThread ,INFINITE);//等待线程结束
	//	delete hThread;//删除线程
	//	SetDlgItemTextW(IDC_BUTTON1, L"开始");
	//}

	state = false;
	DWORD wait_time = 10 * 1000;
	// 主
	if (hThread)
	{
		if (WaitForSingleObject(hThread, wait_time) != 0)
		{
			// 等待线程自然结束失败了,逼不得已我们使用强制结束线程
			TerminateThread(hThread, 0);

		}
		CloseHandle(hThread);
		SetDlgItemTextW(IDC_BUTTON1, L"开始");
		GetDlgItem(IDC_BUTTON1)->EnableWindow(TRUE);
	}
	if (hThread1)
	{
		wait_time = 3000;
		if (WaitForSingleObject(hThread1, wait_time) != 0)
		{
			// 等待线程自然结束失败了,逼不得已我们使用强制结束线程
			TerminateThread(hThread1, 0);
			
		}
		CloseHandle(hThread1);
		
	}
	//hThread = NULL;
	//M_ReleaseAllKey(msdk_handle);
	//int cl = M_Close(msdk_handle);
	//msdk_handle = INVALID_HANDLE_VALUE;	//初始为未打开
	//g_dm->delay(5000);
	//g_dm->KeyDown(16);
	//g_dm->delay(10000);
	//g_dm->KeyUp(16);
	//msdk_handle = M_Open(1);
	//g_dm->delay(5000);
	//jumpA();

	//long hwnd = g_dm->FindWindow(L"MapleStoryClass", L"MapleStory");

	//int ret = g_dm->BindWindowEx(hwnd, L"normal", L"normal", L"dx.keypad.raw.input", L"", 0);
	//g_dm->delay(2000);
	//g_dm->SetWindowState(hwnd, 12);
	//g_dm->MoveWindow(hwnd, 0, 0);

	//g_dm->KeyDown(16);
	//g_dm->delay(10000);
	//g_dm->KeyUp(16);

}


void CGameDlg::OnBnClickedButton3()
{
	// TODO: 在此添加控件通知处理程序代码
	CButton* pBtnJi = (CButton*)GetDlgItem(IDC_CHECK4);
	Sleep(2000);
	long x, y;
	bool state = false;
	bool state1 = false;
	while (pBtnJi->GetCheck()==1)
	{
		
		g_dm->FindPic(0, 0, 1280, 960, L"taskend.bmp", L"101010", 0.9, 0, &x, &y);
		if (x > 0) {
			g_dm->MoveToEx(x+10, y+10,5,5);
			g_dm->LeftClick();
		}
		g_dm->FindPic(0, 0, 1280, 960, L"taskSucess.bmp|npcctrl.bmp|ctrl.bmp", L"101010", 0.9, 0, &x, &y);
		if (x > 0) {
			for (size_t i = 0; i < 10; i++)
			{
				g_dm->KeyDown(17);
				Sleep(RandomNumber(200, 400));
				g_dm->KeyUp(17);
			}
		}
		
		g_dm->FindPic(0, 0, 1280, 960, L"npc.bmp", L"101010", 0.9, 0, &x, &y);
		if (x > 0 && !state1) {
			g_dm->KeyDown(39);
			Sleep(RandomNumber(4300, 4500));
			g_dm->KeyUp(39);
			Sleep(200);
			g_dm->KeyPress(32);
			state1 = true;
		}
		g_dm->FindPic(0, 0, 1280, 960, L"biao.bmp", L"101010", 0.9, 0, &x, &y);
		if (x > 0) {
			if (!state) {
				g_dm->KeyDown(39);
				Sleep(RandomNumber(4300, 4500));
				g_dm->KeyUp(39);
				state = true;
				Sleep(200);
				g_dm->KeyDown(39);
				Sleep(RandomNumber(150, 300));
				g_dm->KeyUp(39);
			}

		}
 		g_dm->FindPic(0, 0, 1280, 960, L"next.bmp", L"101010", 0.9, 0, &x, &y);
		if (x > 0) {
			g_dm->KeyDown(32);
			Sleep(RandomNumber(4000, 6000));
			g_dm->KeyUp(32);
		}
		Sleep(1000);
	}
}

unsigned WINAPI Test(PVOID pParam) {

	Sleep(1000);
	//for (size_t i = 0; i < 11; i++)
	//{
	//	//g_dm->KeyDown(mapKey[L"left"]);
	//	//g_dm->delay(RandomNumber(200, 500));
	//	g_dm->KeyDown(mapKey[L"alt"]);
	//	g_dm->delay(RandomNumber(90,150));
	//	g_dm->KeyUp(mapKey[L"alt"]);
	//	g_dm->delay(RandomNumber(20, 100));
	//	g_dm->KeyDown(mapKey[L"shift"]);
	//	g_dm->delay(RandomNumber(90, 130));
	//	g_dm->KeyUp(mapKey[L"shift"]);
	//	//g_dm->delay(RandomNumber(200, 350));
	//	//g_dm->KeyPress(mapKey[L"shift"]);
	//	//g_dm->delay(RandomNumber(20, 100));
	//	//g_dm->KeyUp(mapKey[L"left"]);
	//	g_dm->delay(RandomNumber(800, 1500));
	//	
	//}
	//return 0;


	long x, y;
	int k = RandomNumber(250, 280);
	while (true)
	{
		CString str;
		if (nI == 1 || nI % k == 0) {
			if (nI != 1) {
				k = RandomNumber(250, 280);
			}
			int curSel = ((CComboBox*)g_main_cwnd->GetDlgItem(IDC_COMBO3))->GetCurSel();
			((CComboBox*)g_main_cwnd->GetDlgItem(IDC_COMBO5))->GetLBText(((CComboBox*)g_main_cwnd->GetDlgItem(IDC_COMBO5))->GetCurSel(), str);

			if (curSel != -1) {
				g_dm->KeyDown(mapKey[L"alt"]);
				g_dm->delay(RandomNumber(90, 150));
				g_dm->KeyUp(mapKey[L"alt"]);
			}

		}
		g_dm->FindPic(0, 0, 1280, 960, L"tag1.bmp", L"050505", 0.98, 0, &x, &y);
		if (x > 0) {
			g_dm->FindPic(x + 30, y, x + 200, y + 35, L"t20.bmp", L"050505", 0.98, 0, &x, &y);
			str.Format(L"第20场：x%d,y%d", x, y);
			g_main_cwnd->AppendText(str);
			gong5();
		}

	
		//g_dm->Capture(0, 0, 1280, 960, str);
		g_dm->FindPic(0, 0, 1280, 960, L"team80.bmp", L"050505", 0.98, 0, &x, &y);
		//str.Format(L"x%d,y%d", x, y);
		//g_main_cwnd->AppendText(str);
		str.Format(L"x%d,y%d:正常打怪", x, y);
		g_main_cwnd->AppendText(str);
		if (x == -1) {
			str.Format(L"打怪结束等待开始");
			g_main_cwnd->AppendText(str);
			g_dm->delay(RandomNumber(7000, 8000));
		}
		g_dm->KeyDown(mapKey[L"alt"]);
		g_dm->delay(RandomNumber(90, 150));
		g_dm->KeyUp(mapKey[L"alt"]);
		g_dm->delay(RandomNumber(20, 100));
		g_dm->KeyDown(mapKey[L"shift"]);
		g_dm->delay(RandomNumber(90, 130));
		g_dm->KeyUp(mapKey[L"shift"]);
		g_dm->delay(RandomNumber(800, 1500));
	}
}
void CGameDlg::OnBnClickedButton4()
{
	
	// TODO: 在此添加控件通知处理程序代码
	//Sleep(2000);
	//g_dm->KeyDown(mapKey[L"left"]);
	//Sleep(1000);
	//g_dm->KeyUp(mapKey[L"left"]);
	//return;
	long x, y;
	g_dm->FindPic(0, 0, 1280, 960, L"dun.bmp", L"101010", 0.9,0, &x, &y);
	CString str;
	str.Format(L"%d,%d", x, y);
	MessageBox(str);

	g_dm->FindPic(0, 0, 1280, 960, L"dun1.bmp", L"101010", 0.9,0, &x, &y);

	str.Format(L"%d,%d", x, y);
	CTime tm;
	tm = CTime::GetCurrentTime();
	//CString str;
	//str = tm.Format(L"%Y%m%d%H%M%S.bmp");
	//g_dm->Capture(0, 0, 1280, 960, str);
	//g_dm->FindPic(0, 0, 1280, 960, L"team80.bmp", L"050505", 0.98, 0, &x, &y);
	//str.Format(L"x%d,y%d", x, y);
	//g_main_cwnd->AppendText(str);

	//g_dm->FindPic(0, 0, 1280, 960, L"tag1.bmp", L"050505", 0.98, 0, &x, &y);
	//
	//if (x > 0) {
	//	g_dm->FindPic(x+30, y, x+200, y+35, L"t20.bmp", L"050505", 0.98, 0, &x, &y);
	//	str.Format(L"第20场：x%d,y%d", x, y);
	//	g_main_cwnd->AppendText(str);
	//}

	//_beginthreadex(0, 0, Test, NULL, 0, 0);
}






#pragma region 人物定点
void CGameDlg::OnBnClickedButton5()
{
	// TODO: 在此添加控件通知处理程序代码


	long x, y;
	g_dm->FindPic(0, 0, 500, 380, L"minMapLeft.bmp", L"202020", 0.9, 0, &x, &y);
	m_mapArr[0] = x;
	m_mapArr[1] = 80;
	g_dm->FindPic(0, 0, 600, 400, L"minMap.bmp", L"000000", 0.98, 0, &x, &y);
	m_mapArr[2] = x + 15;
	m_mapArr[3] = y + 50;
	g_dm->FindPic(0, 0, m_mapArr[2], m_mapArr[3], L"localTag.bmp|localTag1.bmp|localTag2.bmp|localTag3.bmp|localTag4.bmp", L"050505", 0.9, 0, &x, &y);
	g_main_cwnd->SetDlgItemTextW(IDC_EDIT5, NumberToString(x));

}
#pragma endregion